package com.ruoyi.web.controller.warning;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.warning.domain.entity.CameraSetting;
import com.ruoyi.warning.service.ICameraSettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 海康监控配置处理表 前端控制器
 * </p>
 *
 * @author chenhc
 * @since 2025-05-21
 */
@RestController
@RequestMapping("/cameraSetting")
@Api(tags = "海康监控配置", description = "用于处理海康监控配置相关操作的控制器")
public class CameraSettingController {
    @Resource
    private ICameraSettingService cameraSettingService;

    @ApiOperation("获取配置列表")
    @Log(title = "获取配置列表", businessType = BusinessType.SELECT)
    @GetMapping(value = "/getlist")
    public R getlist() {
        return R.ok(cameraSettingService.list());
    }

    @ApiOperation("获取配置详细信息")
    @Log(title = "获取配置详细信息", businessType = BusinessType.SELECT)
    @GetMapping(value = "/getDetail/{id}")
    public R getDetail(@PathVariable String id) {
        return R.ok(cameraSettingService.getById(id));
    }

    @ApiOperation("新增或修改配置")
    @Log(title = "新增或修改配置", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/saveOrUpdate")
    public R saveOrUpdate(@RequestBody CameraSetting cameraSetting){
        cameraSettingService.saveOrUpdate(cameraSetting);
        //还要刷新一下摄像头列表
        return R.ok();
    }

    @ApiOperation("删除配置")
    @Log(title = "删除配置", businessType = BusinessType.DELETE)
    @GetMapping(value = "/delete/{id}")
    public R delete(@PathVariable String id) {
        return R.ok(cameraSettingService.removeById(id));
    }
}
